Skip to content

Read prep/meas noise keys by failing basis in the color-code circuits - #104

Open
ivanbasov wants to merge 1 commit into
mainfrom
fix/color-code-prep-meas-key-convention
Open

ivanbasov wants to merge 1 commit into
mainfrom
fix/color-code-prep-meas-key-convention

Conversation

@ivanbasov

@ivanbasov ivanbasov commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

What

The four prep/meas keys of data.noise_model are named by the basis that fails: p_prep_Z / p_meas_Z belong to Z-basis reset/measurement (applied as X_ERROR), p_prep_X / p_meas_X to X-basis (applied as Z_ERROR). The surface-code builder, conf/config_public.yaml and the README follow this.

The color-code path paired them the other way (Z-basis reset/measurement took p_prep_X / p_meas_X), so a non-uniform noise model had its X-basis and Z-basis rates exchanged. This PR gives the color-code path the same pairing as the surface code. The Pauli applied for each basis is unchanged; only the key that supplies the probability changes.

Changes

  • qec/color_code/memory_circuit.py: add_reset, add_single_error, add_measure_reset, add_measure, and the data-readout flip of the final round.
  • qec/precompute_dem.py: build_single_p_marginal_color_code, so the Torch probability vector keeps matching the Stim circuit.
  • qec/noise_model.py: docstring only.

Impact

Behaviour changes only for the color code with p_prep_X != p_prep_Z or p_meas_X != p_meas_Z; exchange the values within each pair to reproduce earlier results.

All configs under conf/, NoiseModel.from_single_p, NoiseModel.from_si1000 and the pretrained models use equal values within each pair. For these the color-code circuit and probability vector are byte-identical before and after (checked at d=5, both bases).

Tests

  • New test_color_code_prep_meas_key_convention.py: a single non-zero key produces the expected instruction on the expected qubits; the color builder agrees with the surface builder; the DEM precompute agrees with the Stim circuit. Fails on main, passes here.
  • Changed expectations in test_color_augmented_dem_precompute.py, which pinned the old pairing with four distinct values: test_color_single_qubit_noise_probabilities_follow_pauli_labels (renamed ..._follow_basis_labels) and test_color_stim_and_dem_data_noise_locations_match.
  • Local: unittest discover 528 tests, 57 skipped, 1 failure (test_required_model_files_present, pretrained weights not present locally); pytest on the color tests 315 passed, 11 skipped; yapf clean.

🤖 Generated with Claude Code

The color-code Stim builder and the color-code DEM precompute read
p_prep_X, p_prep_Z, p_meas_X and p_meas_Z by the applied Pauli
(Z-basis reset/measure used the *_X keys), while the surface-code
builder, the config comments and the README name a key by the basis
that fails (Z-basis reset/measure uses the *_Z keys and is applied as
X_ERROR). With a non-uniform noise model the color-code path applied
the X-basis rates to the Z basis and vice versa.

Move the color-code readers to the surface-code convention:
- qec/color_code/memory_circuit.py: add_reset, add_single_error,
  add_measure_reset, add_measure and the data-readout flip injected in
  the final round.
- qec/precompute_dem.py: build_single_p_marginal_color_code (ancilla
  prep/meas, data prep and final data-readout entries).

Models with p_prep_X == p_prep_Z and p_meas_X == p_meas_Z, which
includes every shipped config, produce the same circuits and
probability vectors as before.

Tests: add test_color_code_prep_meas_key_convention.py and update the
two expectations in test_color_augmented_dem_precompute.py that pinned
the previous convention.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Ivan Basov <ibasov@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant